package org.atovio.structure.map;

import java.util.Objects;

/**
 * 映射元素类
 * @author AtoVio, Winter Yuan
 * @version 1.0
 */
public class KeyValue<K,V> {
    // 关键字
    public final K key;
    // 映射值
    public V value;

    public KeyValue(K key, V value) {
        this.key = key;
        this.value = value;
    }

    @Override
    public String toString() {
        return "KeyValue{" +
                "key=" + key +
                ", value=" + value +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        KeyValue<?, ?> keyValue = (KeyValue<?, ?>) o;
        return Objects.equals(key, keyValue.key);
    }

    @Override
    public int hashCode() {
        return Objects.hash(key);
    }
}
